<?php if (isset($is_common_home) && $is_common_home): ?>
<div class="container module-bottom"><div class="row"><div class="col-sm-12">
<?php endif ?>
<div class="module-time-product swiper-box swiper-container">
  <div class="swiper-wrapper">
    <?php foreach ($products as $product) { ?>
      <div class="single-product swiper-slide">
        <div class="col-sm-5 col-xs-12">
          <a href="<?php echo $product['href']; ?>">
            <img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" />
          </a>
        </div>
        <div class="col-sm-7 col-xs-12 product-text">
          <p class="title"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></p>
          <div class="rating stars-box">
            <?php for ($i = 1; $i <= 5; $i++) { ?>
            <?php if ($product['rating'] < $i) { ?>
            <span class="fa fa-stack"><i class="fa fa-star off fa-stack-1x"></i></span>
            <?php } else { ?>
            <span class="fa fa-stack"><i class="fa fa-star off fa-stack-1x"></i><i class="fa fa-star fa-stack-1x"></i></span>
            <?php } ?>
            <?php } ?>
          </div>
          <p class="profile"><?php echo $product['description']; ?></p>
          <div class="price">
            <?php if (!$product['special']) { ?>
            <span class="price-price"><?php echo $product['price']; ?></span>
            <?php } else { ?>
            <span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
            <?php } ?>
            <?php if ($product['tax']) { ?>
            <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
            <?php } ?>
          </div>
          <?php if ($product['seconds'] > 0): ?>
          <ul class="countdown countdown" data-countdown="<?php echo $product['seconds']; ?>"></ul>
          <?php endif ?>
          <a href="<?php echo $product['href']; ?>" class="btn btn-primary btn-lg"><?php echo $button_more; ?></a>
        </div>
      </div>
    <?php } ?>
  </div>
  <div class="swiper-pagination swiper-pagination-black"></div>
  <div class="swiper-button-next"><i class="fa fa-angle-right" aria-hidden="true"></i></div>
  <div class="swiper-button-prev"><i class="fa fa-angle-left" aria-hidden="true"></i></div>
</div>
<?php if (isset($is_common_home) && $is_common_home): ?>
</div></div></div>
<?php endif ?>

<script>
  $(document).ready(function() {
    var module_special_swiper = new Swiper('.module-time-product', {
      pagination: {
        el: '.swiper-pagination',
      },
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
      autoplay: {
        delay: 3000,
        disableOnInteraction: false
      },
      loop: true,
      grabCursor: true,
      autoplayDisableOnInteraction: false,
    });

    $('.module-time-product').hover(function() {
      module_special_swiper.autoplay.stop();
    }, function() {
      module_special_swiper.autoplay.start();
    });

    $('[data-countdown]').each(function() {
      var $this = $(this), end = moment().add($(this).data('countdown'), 'seconds').toDate();
      $this.countdown(end, function(event) {
        $this.html(event.strftime('<li><span>%D</span><?php echo $text_day; ?></li> <li><span>%H</span><?php echo $text_hour; ?></li> <li><span>%M</span><?php echo $text_minute; ?></li> <li><span>%S</span><?php echo $text_second; ?></li>'));
      });
    });
  });
</script>
